package com.umpay.util;

/**
 * 
 * @ClassName: StringUtils  
 * @Description: string工具类 
 * @author zhangtao  
 * @date Jan 31, 2018
 */
public class StringUtils {

    public static final String EMPTY = "";

    public static String trim(Object o) {
        if(null != o) {
            return o.toString().trim();
        }
        return "";

    }

    public static boolean isEmpty(String str) {
        str = trim(str);
        if(str.equals("")) {
            return true;
        }else {
            return false;
        }
    }

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }
    
    public static boolean isEmpty(Object object){
    	return object == null;
    }
    
    public static boolean isNotEmpty(Object object){
    	return !isEmpty(object);
    }

    /**
     * <p>Checks if a String is whitespace, empty ("") or null.</p>
     *
     * <pre>
     * StringUtils.isBlank(null)      = true
     * StringUtils.isBlank("")        = true
     * StringUtils.isBlank(" ")       = true
     * StringUtils.isBlank("bob")     = false
     * StringUtils.isBlank("  bob  ") = false
     * </pre>
     *
     * @param str  the String to check, may be null
     * @return <code>true</code> if the String is null, empty or whitespace
     * @since 2.0
     */
    public static boolean isBlank(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if ((Character.isWhitespace(str.charAt(i)) == false)) {
                return false;
            }
        }
        return true;
    }
}
